package c.x.jy.wexin.controller;

import c.x.jy.common.utils.PageUtils;
import c.x.jy.common.utils.R;
import c.x.jy.dao.entity.BannerEntity;
import c.x.jy.service.service.BannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;


/**
 * 
 *
 * @author amwhyh
 * @email xxx@xx.com
 * @date 2021-07-20 14:58:34
 */
@RestController
@RequestMapping("wechat/banner")
public class BannerController {
    @Autowired
    private BannerService bannerService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bannerService.queryPage(params);

        return R.put(page);
    }
    /**
     * 列表for首页
     */
    @RequestMapping("/list6")
    public R list6(){
        List<BannerEntity> list = bannerService.list6();

        return R.put(list);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		BannerEntity banner = bannerService.getById(id);

        return R.put(banner);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody BannerEntity banner){
		bannerService.save(banner);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody BannerEntity banner){
		bannerService.updateById(banner);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete/{id}")
    public R delete(@PathVariable("id") Long id){
		bannerService.removeByIds(Arrays.asList(id));

        return R.ok();
    }

}

